package zpy.servlet.servlet;


import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

/**
 * Servlet implementation class CheckboxRadioServlet
 */
@WebServlet("/CheckboxRadioServlet")
public class CheckboxRadioServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CheckboxRadioServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("text/plain;charset=UTF-8");
		PrintWriter out = response.getWriter();
		request.setCharacterEncoding("UTF-8");
		String[] shicai = request.getParameterValues("shicai");
		String   penrengfangshi = request.getParameter("penrengfangshi");
		String   anonymouscheckbox = request.getParameter("anonymouscheckbox");
		String   anonymousradio = request.getParameter("anonymousradio");
		out.println("食材:");
		for(String s:shicai){
			out.print(s);
			out.print("     ");
		}
		out.println("");
		out.print("匿名checkbox:");
		out.println(anonymouscheckbox);
		out.print("烹饪方式:");
		out.println(penrengfangshi);
		out.print("匿名radio:");
		out.println(anonymousradio);
		out.close();

	}

}
